package com.hamizhong.iflowers.web.action.admin.user;

import java.util.List;

import com.hamizhong.iflowers.service.IUserService;
import com.hamizhong.iflowers.utils.MyTools;
import com.hamizhong.iflowers.web.base.MyBaseAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.IObjectVO;
import com.hamizhong.iflowers.web.vo.UserVO;

public class UserDetailAction extends MyBaseAction {
	
	private IUserService iUserService;
	
	public IUserService getiUserService() {
		return iUserService;
	}
	public void setiUserService(IUserService iUserService) {
		this.iUserService = iUserService;
	}
	
	@Override
	protected String doRequest() {
		logger.info("----------------- Hello UserDetailAction -----------------");
		String userId = getRQ().getParameter("userId");
		IOPResultDto<IObjectVO> dto = iUserService.findByUserId(Integer.valueOf(userId));
		if(dto.isSuccess()) {
			List<UserVO> userVOList = dto.getFirstResult().getUserVOList();
			UserVO userVO = userVOList.get(0);
			userVO.setCreateDateStr(MyTools.formatDttm2YYYY_MM_DD_HH_MM_SS(userVO.getCreateDate()));
			getRQ().setAttribute("userVO", userVO);
			return SUCCESS;
		}else {
			return ERROR;
		}
	}

}
